import React, { useEffect, useState } from 'react'

export default function App() {
    const [isShow, setIsShow] = useState(true)

    return (
        <div>
            <button onClick={() => setIsShow(!isShow)}>显示与隐藏</button>
            {
                isShow && <Child></Child>
            }
        </div>
    )
}
function Child() {
    useEffect(()=>{
        console.log('挂载阶段： componentDidMount')
        return ()=> {
            console.log('卸载阶段：componentWillUnmount')
        }
    },[])
    return (
        <div>
            <h3>Child</h3>
        </div>
    )
}

